<?php 
if(!isset($_SESSION)) 
{ 
	session_start(); 
}
$lang = $_SESSION['lang'];
if (empty($lang) || $lang == "EN") {
	include "../../value/value_en.php";
} else if($lang == "VN") {
	include "../../value/value_vn.php";
}
else {
	include "../../value/value_kr.php";
}
include '../../operations/connection.php';
include("../../content_salary/sa_funcs.php");
$mthu=array();
$mthu[0]='<font color="red" ><b>'.$l_vday_chunhat.'</b></font>';
$mthu[1]=$l_vday_thuhai;
$mthu[2]=$l_vday_thuba;
$mthu[3]=$l_vday_thutu;
$mthu[4]=$l_vday_thunam;
$mthu[5]=$l_vday_thusau;
$mthu[6]='<font color="red" ><b>'.$l_vday_thubay.'</b></font>';
$mthu[7]=" ";
?>
			<table style="width: 100%;" class="rf-dt" id="checktimes">
				<tr>
					<td class="rf-dt-shdr-c" width="10px"><?=$l_no?></td>
					<td class="rf-dt-shdr-c" width="15%"><?=$l_employee_name?></td>
					<td class="rf-dt-shdr-c" width="5%"><?=$l_code?></td>
					<td class="rf-dt-shdr-c" width="5%"><?=$l_thu?></td>
					<td class="rf-dt-shdr-c" width="10%"><?=$l_date?></td>
					<td class="rf-dt-shdr-c" width="5%"><?=$l_timecheckin?></td>
					<td class="rf-dt-shdr-c" width="5%"><?=$l_timecheckout?></td>
					<td class="rf-dt-shdr-c" width="5%"><?=$l_late?></td>
					<td class="rf-dt-shdr-c" width="5%"><?=$l_comebackearly?></td>
					<td class="rf-dt-shdr-c" width="5%"><?=$l_half_dayoff?></td>
					<td class="rf-dt-shdr-c" width="5%"><?=$l_all_dayoff?></td>
					<td class="rf-dt-shdr-c" width="5%"><?=$l_overtime?></td>
					<td class="rf-dt-shdr-c" width="15%"><?=$l_note?></td>
					<td class="rf-dt-shdr-c" width="15%"><?=$l_update_information?></td>
				</tr>
				<?php 
				$sql="select em.IDEmployee as emid,
					em.FullName as emname,
					ct.id,
					ct.employeeID,
					upsuser.FullName as upname ,
					cruser.FullName as crname ,
					ct.employeeName,ct.time_work,
					ct.time_in,ct.time_out,
					ct.is_late,
					ct.is_comeback_early,
					ct.half_day_off,
					ct.all_day_off,
					ct.overtime,
					ct.note,
					ct.user_create,ct.createDate,
					ct.user_update,
					ct.update_date,ct.`status` as stct   
				from sa_check_time ct left join employee em on ct.employeeID = em.EmployeeCode 
				left join  employee upsuser on upsuser.IDEmployee = ct.user_update 
				left join employee cruser on cruser.IDEmployee = ct.user_create 
				where ct.`status`!=1 and ( month(ct.time_work)='".$_REQUEST['months']."' 
				and year(ct.time_work) = '".$_REQUEST['years']."' ) 
				and em.IDEmployee='".$_SESSION['IDEmployee']."' order by ct.employeeID,ct.time_work asc";
				$list = mysql_query($sql);
				if(mysql_num_rows($list)>0){
						$i=1;
					while($row = mysql_fetch_array($list)){
						$thu=getWday($row[time_work]);
					if($thu==6 || $thu==0){
					?>
					<tr style="background:#ccffcc;text-align:center;" >
					<?php 
					}else{
					?>
					<tr style="text-align:center;">
					<?php 
					}
					?>
						<td class="rf-dt-c" width="10px"><?=$i?></td>
						<td class="rf-dt-c" width="15%"><?=$row[emname]?></td>
						<td class="rf-dt-c" width="5%"><?=$row[employeeID]?></td>
						<td class="rf-dt-c" width="5%"><?=$mthu[$thu]?></td>
						<td class="rf-dt-c" width="10%"><?=$row[time_work]?></td>
						<td class="rf-dt-c" width="5%"><?=$row[time_in]?></td>
						<td class="rf-dt-c" width="5%"><?=$row[time_out]?></td>
						<?php 
							if ($row[is_late] != '0'){
								echo '<td class="rf-dt-c" style="font-weight:bold;background:orange;text-align:center;">X</td>';
							}else{
								echo '<td class="rf-dt-c"></td>';
							}
							

							if ($row[is_comeback_early] != '0'){
								echo '<td class="rf-dt-c" style="font-weight:bold;background:yellow;text-align:center;">X</td>';
							}else{
								echo '<td class="rf-dt-c"></td>';
							}

							if ($row[half_day_off] != '0') {
								echo '<td class="rf-dt-c" style="font-weight:bold;background:pink;text-align:center;">X</td>';
							}else{
								echo '<td class="rf-dt-c"></td>';
							}

							if ($row[all_day_off] != '0'){
								echo '<td class="rf-dt-c" style="font-weight:bold;background:red;text-align:center;">X</td>';
							}else{
								echo '<td class="rf-dt-c"></td>';
							}

							if ($row[overtime] != '0') {
								echo '<td class="rf-dt-c" style="font-weight:bold;background:green;text-align:center;">X</td>';
							}else{
								echo '<td class="rf-dt-c"></td>';
							}
						?>
						<td class="rf-dt-c" width="15%"><?=$row[note]?></td>
						<td class="rf-dt-c" width="15%">
						<?php 
						if($row[user_update]==""){
							echo $row[crname]."<br>".$row[createDate];
						}else{
							echo $row[upname]."<br>".$row[update_date];
						}
						?>
						</td>
					</tr>
					<?php 
						$i++;
					}
				}else{
					?>
					<tr><td colspan="14" style="height:24px;valign:middle;padding-left:30px;"><?php echo $l_list_emplty; ?></td></tr>
					<?php 
				}
				?>
			</table>
			<?php mysql_close($connection);?>